// components/calender/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
      checkeddays:{
        type:Array,
        value:[]
      },
      continueddays:{
        type:Number,
        value:0
      }
  },

  /**
   * 组件的初始数据
   */
  data: {
    weeks: ["日", "一", "二", "三","四","五","六"],
    days:[],
    year:0,
    month:0,
    today:0,
  },
  lifetimes:{
    ready(){
      this.init();
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    init(){
      let date = new Date();
      const year = date.getFullYear();
      let month = date.getMonth();
      const today = date.getDate();
      const thisMonthEnd = new Date(year,month+1,0);
      const thisEndDay = thisMonthEnd.getDate();
      month = (++month < 10)?"0"+month:month;
      date.setDate(1);
      let week = date.getDay();
      this.setData({
        year:year,
        month:month,
        today:today
      });
      let days = [];
      for(let i = 1;i<40;i++){
        if(i<=week){
          days.push({
            value:"",
            checked:false,
            show:false
          });
        }else{
          let day = i-week;
          let ischeck = this.data.checkeddays.indexOf(day);
          if(ischeck>=0){
            days.push({
              value: day,
              checked: true,
              show: true
            });
          }else{
            days.push({
              value: day,
              checked: false,
              show: true
            });
          }
          
          if(day==thisEndDay){
            break;
          }
        }
      }
      this.setData({
        days:days
      });
    }
  }
})
